package service
{
	import com.adobe.air.crypto.SimpleEncryptionKeyGenerator;
	
	import flash.data.SQLConnection;
	import flash.data.SQLResult; 
	import flash.data.SQLStatement;
	import flash.filesystem.File;
	import flash.utils.ByteArray;
	
	import enums.weapon.WeaponEnum;
	
	import model.monster.MonsterModel;
	import model.vo.ItemVo;
	import model.vo.weapon.BaseBowGunWeaponVo;
	import model.vo.weapon.BaseShortWeaponVo;
	import model.vo.weapon.BaseWeaponVo;
	import model.vo.weapon.BugStickBugVo;
	import model.vo.weapon.BugStickMotionVo;
	import model.vo.weapon.BugStickVo;
	import model.vo.weapon.ChargeAxeMotionVo;
	import model.vo.weapon.ChargeAxeVo;
	import model.vo.weapon.DoubleSwordMotionVo;
	import model.vo.weapon.FluteMotionVo;
	import model.vo.weapon.FluteStaffVo;
	import model.vo.weapon.FluteVo;
	import model.vo.weapon.GreatSwordMotionVo;
	import model.vo.weapon.GunLanceGunVo;
	import model.vo.weapon.GunLanceMotionVo;
	import model.vo.weapon.GunLanceVo;
	import model.vo.weapon.HammerMotionVo;
	import model.vo.weapon.LanceMotionVo;
	import model.vo.weapon.LightBowGunVo;
	import model.vo.weapon.LongSwordMotionVo;
	import model.vo.weapon.ShortSwordMotionVo;
	import model.vo.weapon.SlashAxeMotionVo;
	import model.vo.weapon.SlashAxeVo;
	
	import org.robotlegs.mvcs.Actor;
	
	import util.ItemUtil;
	import util.WeaponUtil;
	
	
	/**
	 * 数据库服务
	 * @author £iang
	 * 
	 */	
	public class SQLService extends Actor
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 怪物数据库连接 */
		private var _monsterCon:SQLConnection;
		/** 怪物查询表达式 */
		private var _monsterStmt:SQLStatement;
		/** 道具数据库连接 */
		private var _itemCon:SQLConnection;
		/** 道具查询表达式 */
		private var _itemStmt:SQLStatement;
		/** 用户数据库连接 */
		private var _userCon:SQLConnection;
		/** 用户查询表达式 */
		private var _userStmt:SQLStatement;
		/** 武器数据库连接 */
		private var _weaponCon:SQLConnection;
		/** 武器查询表达式 */
		private var _weaponStmt:SQLStatement;
		
		/** 数据库查询结果 */
		private var _sqlResult:SQLResult;
		
		/** 怪物db文件 */
		private var _monsterFile:File;
		/** 道具db文件 */
		private var _itemFile:File;
		/** 用户db文件 */
		private var _userFile:File;
		/** 武器db文件 */
		private var _weaponFile:File;
		
		[Inject]
		public var monsterModel:MonsterModel;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 连接数据库 
		 * 
		 */		
		public function linkDataBase():void
		{
			var keyGenerator:SimpleEncryptionKeyGenerator = 
				new SimpleEncryptionKeyGenerator();
			var encryptionKey:ByteArray = 
				keyGenerator.getEncryptionKey( "qazWSXedcRFV123" );
			
			_monsterFile = File.applicationDirectory.resolvePath("data/monster.db");
			_monsterCon = new SQLConnection();
			_monsterCon.open( _monsterFile, "read", false, 1024, encryptionKey );
			_monsterStmt = new SQLStatement();
			_monsterStmt.sqlConnection = _monsterCon;
			
			_itemFile = File.applicationDirectory.resolvePath("data/item.db");
			_itemCon = new SQLConnection();
			_itemCon.open( _itemFile, "read", false, 1024, encryptionKey );
			_itemStmt = new SQLStatement();
			_itemStmt.sqlConnection = _itemCon;
			
			_userFile = File.applicationDirectory.resolvePath("data/user.db");
			_userCon = new SQLConnection();
			_userCon.open( _userFile, "create", false, 1024, encryptionKey );
			_userStmt = new SQLStatement();
			_userStmt.sqlConnection = _userCon;
			
			_userStmt.text = "create table if not exists sp_table (" +  
				"    spId INTEGER, " +  
				"    id INTEGER, " +  
				"    name TEXT, " +
				"    url TEXT, " +
				"    star INTEGER " +
				")"; 
			_userStmt.execute();
			
			_weaponFile = File.applicationDirectory.resolvePath("data/weapon.db");
			_weaponCon = new SQLConnection();
			_weaponCon.open( _weaponFile, "read", false, 1024, encryptionKey );
			_weaponStmt = new SQLStatement();
			_weaponStmt.sqlConnection = _weaponCon;
		}
		
		/**
		 * 获取当前查看的大型怪物的详细信息 
		 * @param monsterId
		 * 
		 */		
		public function getCurReadLMonsterDetailInfo( monsterId:int ):void
		{
			var len:int;
			var i:int;
			//获取肉质数据
			_monsterStmt.text = "select * from lmonster_meat_table where id = " + monsterId + " order by type";
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			monsterModel.setCurLMonsterMeatData( _sqlResult.data );
			//获取特殊攻击效果数据
			_monsterStmt.text = "select * from lmonster_sp_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			monsterModel.setCurLMonsterSpData( _sqlResult.data );
			//获取道具效果数据
			_monsterStmt.text = "select * from lmonster_item_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			monsterModel.setCurLMonsterItemData( _sqlResult.data );
			//获取剥取&掉落数据
			_monsterStmt.text = "select * from lmonster_collect_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			len = _sqlResult.data.length;
			 
			for ( i = 0; i < len; i ++ )
			{
				_sqlResult.data[ i ].lowVec = getItemsDataByString( _sqlResult.data[ i ].low );
				_sqlResult.data[ i ].highVec = getItemsDataByString( _sqlResult.data[ i ].high );
			}
			
			monsterModel.setCurLMonsterCollectData( _sqlResult.data );
			//获取破坏报酬数据
			_monsterStmt.text = "select * from lmonster_destroy_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( i = 0; i < len; i ++ )
			{
				_sqlResult.data[ i ].lowVec = getItemsDataByString( _sqlResult.data[ i ].low );
				_sqlResult.data[ i ].highVec = getItemsDataByString( _sqlResult.data[ i ].high );
			}
			
			monsterModel.setCurLMonsterDestroyData( _sqlResult.data );
			//获取捕获报酬数据
			_monsterStmt.text = "select * from lmonster_catch_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( i = 0; i < len; i ++ )
			{
				_sqlResult.data[ i ].lowVec = getItemsDataByString( _sqlResult.data[ i ].low );
				_sqlResult.data[ i ].highVec = getItemsDataByString( _sqlResult.data[ i ].high );
			}
			
			monsterModel.setCurLMonsterCatchData( _sqlResult.data );
			//获取出现任务数据
			_monsterStmt.text = "select * from lmonster_appear_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			monsterModel.setCurLMonsterAppearData( _sqlResult.data );
			//获取体型数据
			_monsterStmt.text = "select * from lmonster_size_table where id = " + monsterId + " order by distinction";
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			monsterModel.setCurLMonsterSizeData( _sqlResult.data );
			//获取攻击方式数据
			_monsterStmt.text = "select * from lmonster_attack_table where id = " + monsterId;
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			monsterModel.setCurLMonsterAttackData( _sqlResult.data );
			//获取视频收藏数据
			_userStmt.text = "select * from sp_table where id = " + monsterId + " order by star desc";
			_userStmt.execute();
			_sqlResult = _userStmt.getResult();
			monsterModel.setCurLMonsterVideoData( _sqlResult.data );
		}
		
		/**
		 * 通过String类型获得item列表 
		 * @param str String类型
		 * @return item列表 
		 * 
		 */		
		public function getItemsDataByString( str:String ):Vector.<ItemVo>
		{
			var vec:Vector.<ItemVo> = new Vector.<ItemVo>();
			var tmpResult:SQLResult;
			
			if ( str != "" && str != null )
			{
				_itemStmt.text = "select * from item_table where id in (" + str + ")";
				_itemStmt.execute();
				tmpResult = _itemStmt.getResult();
				
				var len:int = tmpResult.data.length;
				
				for ( var i:int = 0; i < len; i++ )
				{
					vec.push( ItemUtil.mapObj2ItemVo( tmpResult.data[ i ] ) );
				}
			}
		
			return vec;
		}
		
		/**
		 * 通过String类型获得item数量列表 
		 * @param str String类型
		 * @return 数量列表 
		 * 
		 */		
		public function getItemsNumByString( str:String ):Vector.<int>
		{
			var vec:Vector.<int> = new Vector.<int>();
			var arr:Array;
			
			if ( str && str != "" )
				arr = str.split( "," );
			
			if ( arr )
			{
				var len:int = arr.length;
				
				for ( var i:int = 0; i < len; i++ )
				{
					vec.push( arr[ i ] );
				}
			}
			
			return vec;
		}
		
		
		/**
		 * 更新视频数据 
		 * 
		 */		
		public function updateSpData():void
		{
			_userStmt.text = "update sp_table set " +  
				"name = '" + monsterModel.curDealingVideo.name + "', " + 
				"url = '" + monsterModel.curDealingVideo.url + "', " +
				"star = " + monsterModel.curDealingVideo.star + " " +
				"where spId = " + monsterModel.curDealingVideo.spId; 
			_userStmt.execute();
			_userStmt.text = "select * from sp_table where id = " + 
				monsterModel.curReadMonsterId
				+ " order by star desc";
			_userStmt.execute();
			_sqlResult = _userStmt.getResult();
			monsterModel.setCurLMonsterVideoData( _sqlResult.data );
		}
		
		/**
		 * 添加视频数据 
		 * 
		 */		
		public function addSpData():void
		{
			_userStmt.text = 
				"insert into sp_table (id, name, url, star) " +  
				"VALUES (" + monsterModel.curReadMonsterId + 
				", '" + monsterModel.curDealingVideo.name + "'," +
				" '" + monsterModel.curDealingVideo.url + 
				"', " + monsterModel.curDealingVideo.star + ")"; 
			_userStmt.execute();
			_userStmt.text = "select * from sp_table where id = " + 
				monsterModel.curReadMonsterId
				+ " order by star desc";
			_userStmt.execute();
			_sqlResult = _userStmt.getResult();
			monsterModel.setCurLMonsterVideoData( _sqlResult.data );
		}
		
		/**
		 * 删除视频数据 
		 * 
		 */		
		public function deleteSpData():void
		{
			_userStmt.text = "delete from sp_table where spId = " + 
				monsterModel.curDealingVideo.spId; 
			_userStmt.execute();
			_userStmt.text = "select * from sp_table where id = " + 
				monsterModel.curReadMonsterId
				+ " order by star desc";
			_userStmt.execute();
			_sqlResult = _userStmt.getResult();
			monsterModel.setCurLMonsterVideoData( _sqlResult.data );
		}
		
		/**
		 * 获取当前查看类型的小型怪物信息 
		 * @param type 类型
		 * 
		 */		
		public function getCurTypeSMonsterInfo( type:String ):void
		{
			_monsterStmt.text = "select * from smonster_table where type = '" + type + "'";
			_monsterStmt.execute();
			_sqlResult = _monsterStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				_sqlResult.data[ i ].lowVec = getItemsDataByString( _sqlResult.data[ i ].low );
				_sqlResult.data[ i ].highVec = getItemsDataByString( _sqlResult.data[ i ].high );
			}
			
			monsterModel.setCurSMonsterTypeData( _sqlResult.data );
		}
		
		
		/**
		 * 获取近身武器简表信息 
		 * @return 简表信息
		 * 
		 */		
		public function getSimpleShortWeaponListInfo( tableName:String ):Vector.<BaseShortWeaponVo>
		{
			var result:Vector.<BaseShortWeaponVo> = new Vector.<BaseShortWeaponVo>();
			
			_weaponStmt.text = "select weapon_id, name, nickName, rare, attack, attribute, attriNum, isAwaken," +
				"red1, orange1, yellow1, green1, blue1, white1, purple1, red2, orange2," +
				"yellow2, green2, blue2, white2, purple2, isFinal from " + tableName + " order by weapon_id asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				result.push( WeaponUtil.mapObj2ShortWeaponVo1( _sqlResult.data[ i ] ) );
			}
			
			return result;
		}
		
		/**
		 * 获取近身武器详细资料 
		 * @param weaponId 武器id
		 * @param tableName 所在表
		 * @return 详细资料
		 * 
		 */		
		public function getShortWeaponDetailInfo( weaponId:int, tableName:String ):BaseShortWeaponVo
		{
			var result:BaseShortWeaponVo;
			
			_weaponStmt.text = "select * from " + tableName + " where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2ShortWeaponVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		/**
		 * 获取武器升级路线 
		 * @param weaponId 武器id
		 * @param tableName 所在的表
		 * @param result 武器升级路线
		 * 
		 */		
		public function getWeaponRoute( weaponId:int, tableName:String, result:Array ):void
		{
			result.push( weaponId );
			_weaponStmt.text = "select pre from " + tableName +
				" where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
		
			var pre:int = _sqlResult.data[0].pre;
			
			if ( pre >= 1 )
			{
				getWeaponRoute( pre, tableName, result );
			}
		}
		
		/**
		 * 获取部分近身武器的搜索结果 
		 * @param weapon_type 武器表
		 * @param rank 武器等级
		 * @param awake_type 觉醒类型 
		 * @param attribute 属性
		 * @param add 加匠类型
		 * @param blade 包含斩味
		 * @param slot 洞数
		 * @param sort 排序方式
		 * @return 搜索结果
		 * 
		 */		
		public function getShortWeaponSearchData(weapon_type:String, rank:int, awake_type:int, attribute:int, add:int, blade:int, slot:int, sort:int):Vector.<BaseWeaponVo>
		{
			var stext:String = setShortWeaponCommonSearchText( weapon_type, rank, awake_type, attribute, add, blade, slot );
			var sortStr:String = setShortWeaponCommonSortText( sort );
			var result:Vector.<BaseWeaponVo> = new Vector.<BaseWeaponVo>();
			
			if ( sortStr != "sharp" )
				stext += ' order by ' + sortStr + ' desc';
			
			_weaponStmt.text = stext;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			if ( _sqlResult.data )
			{
				var len:int = _sqlResult.data.length;
				var i:int;
				
				if ( sortStr != "sharp" )
				{
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( _sqlResult.data[ i ] ) );
					}
				}
				else
				{
					var tmpArr:Array = sortSharp( _sqlResult.data );
					
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( tmpArr[ i ] ) );
					}
				}
			}
			
			return result;
		}
		
		/**
		 * 获取狩猎笛的搜索结果 
		 * @param weapon_type 武器表
		 * @param rank 武器等级
		 * @param awake_type 觉醒类型 
		 * @param attribute 属性
		 * @param add 加匠类型
		 * @param blade 包含斩味
		 * @param slot 洞数
		 * @param sort 排序方式
		 * @param melodyType 音色类型
		 * @return 搜索结果
		 * 
		 */		
		public function getFluteSearchData(weapon_type:String, rank:int, awake_type:int, attribute:int, add:int, blade:int, slot:int, sort:int, melodyType:int ):Vector.<BaseWeaponVo>
		{
			var stext:String = setShortWeaponCommonSearchText( weapon_type, rank, awake_type, attribute, add, blade, slot );
			var sortStr:String = setShortWeaponCommonSortText( sort );
			var result:Vector.<BaseWeaponVo> = new Vector.<BaseWeaponVo>();
			
			if ( melodyType != -1 )
				stext += WeaponUtil.getMelodyTypeSearchStr( melodyType );
			
			if ( sortStr != "sharp" )
				stext += ' order by ' + sortStr + ' desc';
			
			_weaponStmt.text = stext;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			if ( _sqlResult.data )
			{
				var len:int = _sqlResult.data.length;
				var i:int;
				
				if ( sortStr != "sharp" )
				{
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( _sqlResult.data[ i ] ) );
					}
				}
				else
				{
					var tmpArr:Array = sortSharp( _sqlResult.data );
					
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( tmpArr[ i ] ) );
					}
				}
			}
			
			return result;
		}
		
		/**
		 * 获取铳枪的搜索结果 
		 * @param weapon_type 武器表
		 * @param rank 武器等级
		 * @param awake_type 觉醒类型 
		 * @param attribute 属性
		 * @param add 加匠类型
		 * @param blade 包含斩味
		 * @param slot 洞数
		 * @param sort 排序方式
		 * @param gunType 炮击类型
		 * @return 搜索结果
		 * 
		 */		
		public function getGunLanceSearchData(weapon_type:String, rank:int, awake_type:int, attribute:int, add:int, blade:int, slot:int, sort:int, gunType:int ):Vector.<BaseWeaponVo>
		{
			var stext:String = setShortWeaponCommonSearchText( weapon_type, rank, awake_type, attribute, add, blade, slot );
			var sortStr:String = setShortWeaponCommonSortText( sort );
			var result:Vector.<BaseWeaponVo> = new Vector.<BaseWeaponVo>();
			
			if ( gunType != -1 )
				stext += WeaponUtil.getGunTypeSearchStr( gunType );
			
			if ( sortStr != "sharp" )
			{
				if (sortStr == "") 
					stext += ' order by gunType,gunLevel desc';
				else
					stext += ' order by ' + sortStr + ' desc';
			}
				
			
			_weaponStmt.text = stext;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			if ( _sqlResult.data )
			{
				var len:int = _sqlResult.data.length;
				var i:int;
				
				if ( sortStr != "sharp" )
				{
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( _sqlResult.data[ i ] ) );
					}
				}
				else
				{
					var tmpArr:Array = sortSharp( _sqlResult.data );
					
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( tmpArr[ i ] ) );
					}
				}
			}
			
			return result;
		}
		
		/**
		 * 获取斧类型武器的搜索结果 
		 * @param weapon_type 武器表
		 * @param rank 武器等级
		 * @param awake_type 觉醒类型 
		 * @param attribute 属性
		 * @param add 加匠类型
		 * @param blade 包含斩味
		 * @param slot 洞数
		 * @param sort 排序方式
		 * @param gunType 炮击类型
		 * @return 搜索结果
		 * 
		 */		
		public function getAxeSearchData(weapon_type:String, rank:int, awake_type:int, attribute:int, add:int, blade:int, slot:int, sort:int, bottle:int ):Vector.<BaseWeaponVo>
		{
			var stext:String = setShortWeaponCommonSearchText( weapon_type, rank, awake_type, attribute, add, blade, slot );
			var sortStr:String = setShortWeaponCommonSortText( sort );
			var result:Vector.<BaseWeaponVo> = new Vector.<BaseWeaponVo>();
			
			if ( bottle != -1 )
				stext += " and bottle = " + bottle;
			
			if ( sortStr != "sharp" )
			{
				if (sortStr == "") 
					stext += ' order by bottle desc';
				else
					stext += ' order by ' + sortStr + ' desc';
			}
			
			_weaponStmt.text = stext;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			if ( _sqlResult.data )
			{
				var len:int = _sqlResult.data.length;
				var i:int;
				
				if ( sortStr != "sharp" )
				{
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( _sqlResult.data[ i ] ) );
					}
				}
				else
				{
					var tmpArr:Array = sortSharp( _sqlResult.data );
					
					for ( i = 0; i < len; i ++ )
					{
						result.push( WeaponUtil.mapObj2BaseWeaponVo( tmpArr[ i ] ) );
					}
				}
			}
			
			return result;
		}
		
		public function setShortWeaponCommonSearchText( weapon_type:String, rank:int, awake_type:int, attribute:int, add:int, blade:int, slot:int):String
		{
			var stext:String = 'select * from ' + weapon_type +'_table where finalType = ' + rank;
			
			if ( attribute != -1 )
			{
				if ( awake_type == 0 )
				{
					if ( attribute == WeaponEnum.NONE )
					{
						stext += ' and isAwaken = true';
					}
					else
					{
						stext += ' and attribute = ' + attribute;
					}
				}
				else if ( awake_type == 1 )
				{
					if ( attribute == WeaponEnum.NONE )
					{
						stext += ' and isAwaken = true';
					}
					else
					{
						stext += ' and attribute = ' + attribute + 
							' and isAwaken = false';
					}
				}
				else if ( awake_type == 2 )
				{
					stext += ' and attribute = ' + attribute + 
						' and isAwaken = true';
				}
			}
			else
			{
				if ( awake_type == 2 )
				{
					stext += ' and isAwaken = true and attribute != 0';
				}
			}
			
			
			if(blade != 0)
			{
				if(add == 1)
				{
					switch(blade)
					{
						case 1:
						{
							stext += ' and red1 > 0';
							break;
						}
						case 2:
						{
							stext += ' and orange1 > 0';
							break;
						}
						case 3:
						{
							stext += ' and yellow1 > 0';
							break;
						}
						case 4:
						{
							stext += ' and green1 > 0';
							break;
						}
						case 5:
						{
							stext += ' and blue1 > 0';
							break;
						}
						case 6:
						{
							stext += ' and white1 > 0';
							break;
						}
						case 7:
						{
							stext += ' and purple1 > 0';
							break;
						}
					}
				}
				else
				{
					switch(blade)
					{
						case 1:
						{
							stext += ' and red2 > 0';
							break;
						}
						case 2:
						{
							stext += ' and orange2 > 0';
							break;
						}
						case 3:
						{
							stext += ' and yellow2 > 0';
							break;
						}
						case 4:
						{
							stext += ' and green2 > 0';
							break;
						}
						case 5:
						{
							stext += ' and blue2 > 0';
							break;
						}
						case 6:
						{
							stext += ' and white2 > 0';
							break;
						}
						case 7:
						{
							stext += ' and purple2 > 0';
							break;
						}
					}
				}
			}
			
			if(slot >= 0)
			{
				stext += ' and slot = ' + slot;
			}
			
			return stext;
		}
		
		public function setShortWeaponCommonSortText( sort:int):String
		{
			var sortStr:String = "";
			
			switch(sort)
			{
				case WeaponEnum.ATTACK_SORT:
				{
					sortStr = "attack";
					break;
				}
					
				case WeaponEnum.ATTRI_SORT:
				{
					sortStr = "attriNum";
					break;
				}
					
				case WeaponEnum.SHARP_SORT:
				{
					sortStr = "sharp";
					break;
				}
					
				case WeaponEnum.CTR_SORT:
				{
					sortStr = "critical";
					break;
				}
					
				case WeaponEnum.SLOT_SORT:
				{
					sortStr = "slot";
					break;
				}
					
				default:
				{
					break;
				}
			}
			
			return sortStr;
		}
		
		public function sortSharp( origin:Array ):Array
		{
			var result:Array = new Array();
			var i:int;
			var j:int;
			var len:int;
			var obj:Object = null;
			
			len = origin.length;
			result.push(origin[0]);
			
			for( i = 1; i < len; i++)
			{
				obj = origin[i];
				
				for( j = 0; j < result.length; j++)
				{	
					var objBladeArr:Array = [obj.red2, obj.orange2, obj.yellow2,
						obj.green2, obj.blue2, obj.white2, obj.purple2];
					var tmpBladeArr:Array = [result[j].red2, result[j].orange2, result[j].yellow2,
						result[j].green2, result[j].blue2, result[j].white2, result[j].purple2];
					
					if( WeaponUtil.isSharper(objBladeArr, tmpBladeArr, 6))
					{
						result.splice(j, 0, obj);
						break;
					}
					else if( j == result.length - 1 )
					{
						result.push(obj);
						break;
					}
				}
			}
			
			return result;
		}
		
		
		public function getBowGunSearchData( weapon_type:String, rank:int, limitBreak:int, reaction:int, reloadSpeed:int, specialBullet:int, slot:int, sort:int):Vector.<BaseWeaponVo>
		{
			var stext:String = setBowGunCommonSearchText( weapon_type, rank, limitBreak, reaction, reloadSpeed, specialBullet, slot );
			var sortStr:String = setBowGunCommonSortText( sort );
			var result:Vector.<BaseWeaponVo> = new Vector.<BaseWeaponVo>();
			
			stext += ' order by ' + sortStr + ' desc';
			
			_weaponStmt.text = stext;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			if ( _sqlResult.data )
			{
				var len:int = _sqlResult.data.length;
				var i:int;
				
				for ( i = 0; i < len; i ++ )
				{
					result.push( WeaponUtil.mapObj2BaseWeaponVo( _sqlResult.data[ i ] ) );
				}
			}
			
			return result;
		}
		
		/**
		 * 获取弩类通用搜索文本 
		 * @param weapon_type 武器类型
		 * @param rank 级别
		 * @param limitBreak 是否限解
		 * @param reaction 反动
		 * @param reloadSpeed 装速
		 * @param specialBullet 特殊弹种
		 * @param slot 洞数
		 * @return 搜索文本
		 * 
		 */		
		public function setBowGunCommonSearchText( weapon_type:String, rank:int, limitBreak:int, reaction:int, reloadSpeed:int, specialBullet:int, slot:int):String
		{
			var stext:String = 'select * from ' + weapon_type +'_table where finalType = ' + rank;
			
			if ( limitBreak > 0 )
			{
				stext += ' and limitBreakPrice > 0';
			}
			
			stext += ' and reaction >= ' + reaction;
			stext += ' and reloadSpeed >= ' + reloadSpeed;
			
			if ( specialBullet >= 0 )
			{
				stext += " and ( specialBullet like '" + specialBullet + ",%' or specialBullet like '%," + specialBullet + ",%' or specialBullet like '%," + specialBullet + "' or specialBullet like '" + specialBullet + "' )";
			}
			
			if ( slot >= 0 )
			{
				stext += ' and slot = ' + slot;
			}
			
			return stext;
		}
		
		/**
		 * 获取弩类排序通用搜索文本 
		 * @param sort 排序类型
		 * @return 通用文本
		 * 
		 */		
		public function setBowGunCommonSortText( sort:int ):String
		{
			var sortStr:String = "";
			
			switch(sort)
			{
				case WeaponEnum.ATTACK_SORT:
				{
					sortStr = "attack";
					break;
				}
					
				case WeaponEnum.RELOAD_SORT:
				{
					sortStr = "reloadSpeed";
					break;
				}
					
				case WeaponEnum.REACTION_SORT:
				{
					sortStr = "reaction";
					break;
				}
					
				case WeaponEnum.CTR_SORT:
				{
					sortStr = "critical";
					break;
				}
					
				case WeaponEnum.SLOT_SORT:
				{
					sortStr = "slot";
					break;
				}
					
				default:
				{
					break;
				}
			}
			
			return sortStr;
		}
		
		/**
		 * 获取大剑动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getGreatSwordMotion():Vector.<GreatSwordMotionVo>
		{
			var result:Vector.<GreatSwordMotionVo> = new Vector.<GreatSwordMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:GreatSwordMotionVo;
			
			_weaponStmt.text = "select * from great_sword_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new GreatSwordMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.fatigue = obj.fatigue;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取太刀动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getLongSwordMotion():Vector.<LongSwordMotionVo>
		{
			var result:Vector.<LongSwordMotionVo> = new Vector.<LongSwordMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:LongSwordMotionVo;
			
			_weaponStmt.text = "select * from long_sword_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new LongSwordMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.addNum = obj.addNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取片手剑动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getShortSwordMotion():Vector.<ShortSwordMotionVo>
		{
			var result:Vector.<ShortSwordMotionVo> = new Vector.<ShortSwordMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:ShortSwordMotionVo;
			
			_weaponStmt.text = "select * from short_sword_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new ShortSwordMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.fatigue = obj.fatigue;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取双刀动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getDoubleSwordMotion():Vector.<DoubleSwordMotionVo>
		{
			var result:Vector.<DoubleSwordMotionVo> = new Vector.<DoubleSwordMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:DoubleSwordMotionVo;
			
			_weaponStmt.text = "select * from double_sword_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new DoubleSwordMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.motionNum2 = obj.motionNum2;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.hit = obj.hit;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取锤子动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getHammerMotion():Vector.<HammerMotionVo>
		{
			var result:Vector.<HammerMotionVo> = new Vector.<HammerMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:HammerMotionVo;
			
			_weaponStmt.text = "select * from hammer_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new HammerMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.fatigue = obj.fatigue;
				motionVo.dizzy = obj.dizzy;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取长枪动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getLanceMotion():Vector.<LanceMotionVo>
		{
			var result:Vector.<LanceMotionVo> = new Vector.<LanceMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:LanceMotionVo;
			
			_weaponStmt.text = "select * from lance_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new LanceMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.fatigue = obj.fatigue;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取笛子简表信息 
		 * @return 简表信息
		 * 
		 */		
		public function getSimpleFluteListInfo():Vector.<FluteVo>
		{
			var result:Vector.<FluteVo> = new Vector.<FluteVo>();
			
			_weaponStmt.text = "select weapon_id, name, nickName, rare, attack, melody," +
				"red1, orange1, yellow1, green1, blue1, white1, purple1, red2, orange2," +
				"yellow2, green2, blue2, white2, purple2, isFinal from flute_table order by weapon_id asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				result.push( WeaponUtil.mapObj2FluteVo1( _sqlResult.data[ i ] ) );
			}
			
			return result;
		}
		
		/**
		 * 获取笛子详细资料 
		 * @param weaponId 武器id
		 * @return 详细资料
		 * 
		 */		
		public function getFluteDetailInfo( weaponId:int ):FluteVo
		{
			var result:FluteVo;
			
			_weaponStmt.text = "select * from flute_table where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2FluteVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		/**
		 * 获取笛子动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getFluteMotion():Vector.<FluteMotionVo>
		{
			var result:Vector.<FluteMotionVo> = new Vector.<FluteMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:FluteMotionVo;
			
			_weaponStmt.text = "select * from flute_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new FluteMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.fatigue = obj.fatigue;
				motionVo.dizzy = obj.dizzy;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取笛子旋律数据 
		 * @param type 音色类型
		 * @return 数据
		 * 
		 */		
		public function getFluteStaff( type:int ):Vector.<FluteStaffVo>
		{
			var result:Vector.<FluteStaffVo> = new Vector.<FluteStaffVo>();
			var len:int;
			var obj:Object;
			var staffVo:FluteStaffVo;
			
			_weaponStmt.text = "select * from melody_table where type = " + type;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				staffVo = new FluteStaffVo();
				staffVo.melody = ( obj.melody as String ).split( "," );
				staffVo.effect = obj.effect;
				staffVo.time = obj.time;
				staffVo.reEffect = obj.reEffect;
				staffVo.reTime = obj.reTime;
				staffVo.ps = obj.ps;
				result.push( staffVo );
			}
			
			return result;
		}
		
		/**
		 * 获取铳枪简表信息 
		 * @return 简表信息
		 * 
		 */		
		public function getSimpleGunLanceListInfo():Vector.<GunLanceVo>
		{
			var result:Vector.<GunLanceVo> = new Vector.<GunLanceVo>();
			
			_weaponStmt.text = "select weapon_id, name, nickName, rare, attack, gunType, gunLevel," +
				"red1, orange1, yellow1, green1, blue1, white1, purple1, red2, orange2," +
				"yellow2, green2, blue2, white2, purple2, isFinal from gun_lance_table order by weapon_id asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				result.push( WeaponUtil.mapObj2GunLanceVo1( _sqlResult.data[ i ] ) );
			}
			
			return result;
		}
		
		/**
		 * 获取铳枪详细资料 
		 * @param weaponId 武器id
		 * @return 详细资料
		 * 
		 */		
		public function getGunLanceDetailInfo( weaponId:int ):GunLanceVo
		{
			var result:GunLanceVo;
			
			_weaponStmt.text = "select * from gun_lance_table where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2GunLanceVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		/**
		 * 获取铳枪动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getGunLanceMotion():Vector.<GunLanceMotionVo>
		{
			var result:Vector.<GunLanceMotionVo> = new Vector.<GunLanceMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:GunLanceMotionVo;
			
			_weaponStmt.text = "select * from gun_lance_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new GunLanceMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取铳枪炮击性能数据 
		 * @return 数据
		 * 
		 */		
		public function getGunLanceGun():Vector.<GunLanceGunVo>
		{
			var result:Vector.<GunLanceGunVo> = new Vector.<GunLanceGunVo>();
			var len:int;
			var obj:Object;
			var gunVo:GunLanceGunVo;
			
			_weaponStmt.text = "select * from gun_lance_gun";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				gunVo = new GunLanceGunVo();
				gunVo.type = obj.type;
				gunVo.loadNum = obj.loadNum;
				gunVo.distance = obj.distance;
				gunVo.range = obj.range;
				gunVo.singePower1 = obj.singePower1;
				gunVo.singePower2 = obj.singePower2;
				gunVo.singePower3 = obj.singePower3;
				gunVo.singePower4 = obj.singePower4;
				gunVo.singePower5 = obj.singePower5;
				gunVo.singleExpend = obj.singleExpend;
				gunVo.singleCharge = obj.singleCharge;
				gunVo.fullBuster = obj.fullBuster;
				gunVo.cannonPower1 = obj.cannonPower1;
				gunVo.cannonPower2 = obj.cannonPower2;
				gunVo.cannonPower3 = obj.cannonPower3;
				gunVo.cannonPower4 = obj.cannonPower4;
				gunVo.cannonPower5 = obj.cannonPower5;
				gunVo.cannonExpend = obj.cannonExpend;
				gunVo.cannonRatio = obj.cannonRatio;
				result.push( gunVo );
			}
			
			return result;
		}
		
		/**
		 * 获取斩击斧简表信息 
		 * @return 简表信息
		 * 
		 */		
		public function getSimpleSlashAxeListInfo():Vector.<SlashAxeVo>
		{
			var result:Vector.<SlashAxeVo> = new Vector.<SlashAxeVo>();
			
			_weaponStmt.text = "select weapon_id, name, nickName, rare, attack, bottle," +
				"red1, orange1, yellow1, green1, blue1, white1, purple1, red2, orange2," +
				"yellow2, green2, blue2, white2, purple2, isFinal from slash_axe_table order by weapon_id asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				result.push( WeaponUtil.mapObj2SlashAxeVo1( _sqlResult.data[ i ] ) );
			}
			
			return result;
		}
		
		/**
		 * 获取斩击斧详细资料 
		 * @param weaponId 武器id
		 * @return 详细资料
		 * 
		 */		
		public function getSlashAxeDetailInfo( weaponId:int ):SlashAxeVo
		{
			var result:SlashAxeVo;
			
			_weaponStmt.text = "select * from slash_axe_table where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2SlashAxeVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		/**
		 * 获取斩击斧动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getSlashAxeMotion():Vector.<SlashAxeMotionVo>
		{
			var result:Vector.<SlashAxeMotionVo> = new Vector.<SlashAxeMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:SlashAxeMotionVo;
			
			_weaponStmt.text = "select * from slash_axe_motion order by mode";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new SlashAxeMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.groove = obj.groove;
				motionVo.mode = obj.mode;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取充能斧简表信息 
		 * @return 简表信息
		 * 
		 */		
		public function getSimpleChargeAxeListInfo():Vector.<ChargeAxeVo>
		{
			var result:Vector.<ChargeAxeVo> = new Vector.<ChargeAxeVo>();
			
			_weaponStmt.text = "select weapon_id, name, nickName, rare, attack, bottle," +
				"red1, orange1, yellow1, green1, blue1, white1, purple1, red2, orange2," +
				"yellow2, green2, blue2, white2, purple2, isFinal from charge_axe_table order by weapon_id asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				result.push( WeaponUtil.mapObj2ChargeAxeVo1( _sqlResult.data[ i ] ) );
			}
			
			return result;
		}
		
		/**
		 * 获取充能斧详细资料 
		 * @param weaponId 武器id
		 * @return 详细资料
		 * 
		 */		
		public function getChargeAxeDetailInfo( weaponId:int ):ChargeAxeVo
		{
			var result:ChargeAxeVo;
			
			_weaponStmt.text = "select * from charge_axe_table where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2ChargeAxeVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		/**
		 * 获取充能斧动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getChargeAxeMotion():Vector.<ChargeAxeMotionVo>
		{
			var result:Vector.<ChargeAxeMotionVo> = new Vector.<ChargeAxeMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:ChargeAxeMotionVo;
			
			_weaponStmt.text = "select * from charge_axe_motion order by mode";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new ChargeAxeMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.mode = obj.mode;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取操虫棍详细资料 
		 * @param weaponId 武器id
		 * @return 详细资料
		 * 
		 */		
		public function getBugStickDetailInfo( weaponId:int ):BugStickVo
		{
			var result:BugStickVo;
			
			_weaponStmt.text = "select * from bug_stick_table where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2BugStickVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		/**
		 * 获取操虫棍动作值数据 
		 * @return 数据
		 * 
		 */		
		public function getBugStickMotion():Vector.<BugStickMotionVo>
		{
			var result:Vector.<BugStickMotionVo> = new Vector.<BugStickMotionVo>();
			var len:int;
			var obj:Object;
			var motionVo:BugStickMotionVo;
			
			_weaponStmt.text = "select * from bug_stick_motion";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				motionVo = new BugStickMotionVo();
				motionVo.attackName = obj.attackName;
				motionVo.motionNum = obj.motionNum;
				motionVo.physicalAdd = obj.physicalAdd;
				motionVo.attriAdd = obj.attriAdd;
				motionVo.ps = obj.ps;
				result.push( motionVo );
			}
			
			return result;
		}
		
		/**
		 * 获取操虫棍猎虫培养数据 
		 * @param type 类型
		 * @return 数据
		 * 
		 */		
		public function getBugStickBug( type:int ):Vector.<BugStickBugVo>
		{
			var result:Vector.<BugStickBugVo> = new Vector.<BugStickBugVo>();
			var len:int;
			var obj:Object;
			var bugVo:BugStickBugVo;
			
			_weaponStmt.text = "select * from bug_stick_bug where " +
				"type = 0 or type = " + type + " order by level asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			len = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				obj = _sqlResult.data[ i ];
				bugVo = new BugStickBugVo();
				bugVo.level = obj.level;
				bugVo.beatName = obj.beatName;
				bugVo.cutName = obj.cutName;
				bugVo.point = obj.point;
				bugVo.skillPoint = obj.skillPoint;
				bugVo.skill = obj.skill;
				bugVo.item = getItemsDataByString( obj.item );
				bugVo.itemNum = ( obj.itemNum as String ).split( "," );
				bugVo.beatImage = obj.beatImage;
				bugVo.cutImage = obj.cutImage;
				result.push( bugVo );
			}
			
			return result;
		}
		
		/**
		 * 获取弩类武器简表信息 
		 * @return 简表信息
		 * 
		 */		
		public function getSimpleBowGunWeaponListInfo( tableName:String ):Vector.<BaseBowGunWeaponVo>
		{
			var result:Vector.<BaseBowGunWeaponVo> = new Vector.<BaseBowGunWeaponVo>();
			
			_weaponStmt.text = "select weapon_id, name, nickName, rare, attack, reloadSpeed, reaction, offsetDirection," +
				"offsetLevel, specialBullet, isFinal from " + tableName + " order by weapon_id asc";
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			var len:int = _sqlResult.data.length;
			
			for ( var i:int = 0; i < len; i ++ )
			{
				result.push( WeaponUtil.mapObj2BowGunVo( _sqlResult.data[ i ] ) );
			}
			
			return result;
		}
		
		/**
		 * 获取轻弩详细资料 
		 * @param weaponId 武器id
		 * @return 详细资料
		 * 
		 */		
		public function getLightBowGunDetailInfo( weaponId:int ):LightBowGunVo
		{
			var result:LightBowGunVo;
			
			_weaponStmt.text = "select * from light_bow_gun_table where weapon_id = " + weaponId;
			_weaponStmt.execute();
			_sqlResult = _weaponStmt.getResult();
			
			_sqlResult.data[ 0 ].produceItemVec = getItemsDataByString( _sqlResult.data[ 0 ].produceItem );
			_sqlResult.data[ 0 ].produceNumVec = getItemsNumByString( _sqlResult.data[ 0 ].produceNum );
			_sqlResult.data[ 0 ].strengthItemVec = getItemsDataByString( _sqlResult.data[ 0 ].strengthItem );
			_sqlResult.data[ 0 ].strengthNumVec = getItemsNumByString( _sqlResult.data[ 0 ].strengthNum );
			_sqlResult.data[ 0 ].identifyItemVec = getItemsDataByString( _sqlResult.data[ 0 ].identifyItem );
			_sqlResult.data[ 0 ].identifyNumVec = getItemsNumByString( _sqlResult.data[ 0 ].identifyNum );
			result = WeaponUtil.mapObj2LightBowGunVo2( _sqlResult.data[0] );
			
			return result;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function SQLService()
		{
			super();
		}
	}
}